<template>
  <div>
    <!--排班管理-->
    <div
      class="yiJi paiBan"
      v-if="Management == 'WorkManagement'"
    >
      <div class="h0">
        <p class="lt">排班管理</p>
        <p class="rt">
          <button
            class="btn btn-info"
            @click="toJump('Scheduling')"
          >排版设置</button>
          <button class="btn btn-default">刷新</button>
        </p>
      </div>
      <div class="m0">
        <div class="form-group clearfix">
          <p>
            <label>门诊科室：</label>
            <select
              class="form-control"
              style="width:110px"
              v-model="options.section"
            >
              <option>全科门诊</option>
            </select>
          </p>
          <p>
            <label>科室医生：</label>
            <select
              class="form-control"
              style="width:110px"
              v-model="options.doctor"
            >
              <option>所有医生</option>
              <option>管理员</option>
            </select>
          </p>
          <p>
            <button
              class="btn btn-primary"
              @click="SearchSuling()"
            >搜索</button>
            <button
              class="btn btn-primary"
              @click="queryG()"
            >查询字典</button>
          </p>
        </div>
        <table class="table table-bordered">
          <thead>
            <tr>
              <th colspan="9">查询/修改预约信息</th>
            </tr>
            <tr>
              <th>医生</th>
              <th>时间</th>
              <th>
                <span>2019-07-11</span>周四
              </th>
              <th>
                <span>2019-07-12</span>周五
              </th>
              <th style="color:red">
                <span>2019-07-13</span>周六
              </th>
              <th style="color:red">
                <span>2019-07-14</span>周日
              </th>
              <th>
                <span>2019-07-15</span>周一
              </th>
              <th>
                <span>2019-07-16</span>周二
              </th>
              <th>
                <span>2019-07-17</span>周三
              </th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td rowspan="100">管理员</td>
              <td>上午</td>
              <td></td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
              <td></td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
            </tr>
            <tr>
              <td>下午</td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
              <td></td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
              <td>
                <a>(0/20)</a>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <!--弹框： 查看班次时间段信息-->
    <div
      class="blackBg"
      style="display:none"
    >
      <div class="banCi panel-default">
        <em
          class="closes"
          onclick="$('.blackBg').hide()"
        >×</em>
        <div class="panel-heading">查看班次时间段信息</div>
        <div class="main">
          <p>
            出诊医师：
            <span>管理员</span>
          </p>
          <p>
            出诊日期：
            <span>2019-07-12 下午</span>
          </p>
          <table class="table table-bordered">
            <thead>
              <tr>
                <th>序号</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>已预约人数/放号数</th>
                <th>状态</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>1</td>
                <td>08:00</td>
                <td>08:30</td>
                <td>0/3</td>
                <td>已过期</td>
                <td>
                  <button class="btn">已过期</button>
                </td>
              </tr>
              <tr>
                <td>2</td>
                <td>08:30</td>
                <td>09:00</td>
                <td>0/3</td>
                <td style="color:green">可以预约</td>
                <td>
                  <button class="btn btn-danger">停诊</button>
                </td>
              </tr>
              <tr>
                <td>3</td>
                <td>09:00</td>
                <td>09:30</td>
                <td>0/3</td>
                <td style="color:green">可以预约</td>
                <td>
                  <button class="btn btn-danger">停诊</button>
                </td>
              </tr>
              <tr>
                <td>4</td>
                <td>09:30</td>
                <td>10:00</td>
                <td>0/3</td>
                <td style="color:green">可以预约</td>
                <td>
                  <button class="btn btn-danger">停诊</button>
                </td>
              </tr>
              <tr>
                <td>5</td>
                <td>10:00</td>
                <td>10:30</td>
                <td>0/3</td>
                <td style="color:green">可以预约</td>
                <td>
                  <button class="btn btn-danger">停诊</button>
                </td>
              </tr>
              <tr>
                <td>6</td>
                <td>10:30</td>
                <td>11:00</td>
                <td>0/3</td>
                <td style="color:green">可以预约</td>
                <td>
                  <button class="btn btn-danger">停诊</button>
                </td>
              </tr>
              <tr>
                <td>7</td>
                <td>11:00</td>
                <td>11:30</td>
                <td>0/3</td>
                <td style="color:green">可以预约</td>
                <td>
                  <button class="btn btn-danger">停诊</button>
                </td>
              </tr>
              <tr>
                <td>8</td>
                <td>11:30</td>
                <td>12:00</td>
                <td>0/3</td>
                <td style="color:red">停诊</td>
                <td>
                  <button class="btn">已停诊</button>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="modal-footer">
          <button
            type="button"
            class="btn btn-default"
            onclick="$('.blackBg').hide()"
          >关闭</button>
        </div>
      </div>
    </div>
    <!--排班设置-->
    <div
      class="yiJi paiBan"
      v-if="Management == 'Scheduling'"
    >
      <div class="h0">
        <p class="lt">
          <span class="prevA">
            <i @click="toJump('WorkManagement')">{{name}}返回上一级</i>|
          </span>排班设置
        </p>
      </div>
      <div class="m0">
        <div class="form-group clearfix">
          <p>
            <label>门诊科室：</label>
            <select
              class="form-control"
              style="width:110px"
            >
              <option>全科门诊</option>
            </select>
          </p>
          <p>
            <label>科室医生：</label>
            <select
              class="form-control"
              style="width:110px"
            >
              <option>所有医生</option>
              <option>管理员</option>
            </select>
          </p>
          <p>
            <button class="btn btn-primary">搜索</button>
            <button class="btn btn-info">生成排班</button>
          </p>
        </div>
        <table class="table table-bordered">
          <thead>
            <tr>
              <th colspan="10">每周排班模板设置</th>
            </tr>
            <tr>
              <th>
                <input type="checkbox" />
              </th>
              <th>医生</th>
              <th>时间</th>
              <th>星期一</th>
              <th>星期二</th>
              <th>星期三</th>
              <th>星期四</th>
              <th>星期五</th>
              <th style="color:red">星期六</th>
              <th style="color:red">星期日</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td rowspan="100">
                <input type="checkbox" />
              </td>
              <td rowspan="100">管理员</td>
              <td style="color:red">操作</td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('1')"
                ></a>
              </td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('2')"
                ></a>
              </td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('3')"
                ></a>
              </td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('4')"
                ></a>
              </td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('5')"
                ></a>
              </td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('6')"
                ></a>
              </td>
              <td>
                <a
                  class="fa fa-edit"
                  @click="JumpblaBg('0')"
                ></a>
              </td>
            </tr>
            <tr>
              <td>上午</td>
              <td>{{Shang.oneShang}}</td>
              <td>{{Shang.TwoShang}}</td>
              <td>{{Shang.ThreeShang}}</td>
              <td>{{Shang.FourShang}}</td>
              <td>{{Shang.FiveShang}}</td>
              <td>{{Shang.SixShang}}</td>
              <td>{{Shang.ZeroShang}}</td>
            </tr>
            <tr>
              <td>下午</td>
              <td>{{Xia.oneShang}}</td>
              <td>{{Xia.TwoShang}}</td>
              <td>{{Xia.ThreeShang}}</td>
              <td>{{Xia.FourShang}}</td>
              <td>{{Xia.FiveShang}}</td>
              <td>{{Xia.SixShang}}</td>
              <td>{{Xia.ZeroShang}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>

    <!--弹框： 医生班次时间段设置-->
    <div
      class="blackBg"
      v-if="blaBg == true"
    >
      <div class="banCi panel-default">
        <em
          class="closes"
          @click="PostblaBg()"
        >×</em>
        <div class="panel-heading">医生班次时间段设置</div>
        <div class="main2">
          <table class="table table-bordered">
            <thead>
              <tr>
                <th colspan="4">上午开诊</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>是否开诊：</td>
                <td>
                  <select
                    class="form-control"
                    style="width: 72px"
                    @change="getoptions()"
                    v-model="WhethOpctor"
                  >
                    <option :value="1">是</option>
                    <option :value="0">否</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td>开始时间：</td>
                <td>
                  <select
                    class="form-control"
                    style="width:72px"
                  >
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option selected>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                  </select> :
                  <select
                    class="form-control"
                    style="width:72px"
                  >
                    <option>00</option>
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                    <option>13</option>
                    <option>14</option>
                    <option>15</option>
                    <option>16</option>
                    <option>17</option>
                    <option>18</option>
                    <option>19</option>
                    <option>20</option>
                    <option>21</option>
                    <option>22</option>
                    <option>23</option>
                    <option>24</option>
                    <option>25</option>
                    <option>26</option>
                    <option>27</option>
                    <option>28</option>
                    <option>29</option>
                    <option>30</option>
                    <option>31</option>
                    <option>32</option>
                    <option>33</option>
                    <option>34</option>
                    <option>35</option>
                    <option>36</option>
                    <option>37</option>
                    <option>38</option>
                    <option>39</option>
                    <option>40</option>
                    <option>41</option>
                    <option>42</option>
                    <option>43</option>
                    <option>44</option>
                    <option>45</option>
                    <option>46</option>
                    <option>47</option>
                    <option>48</option>
                    <option>49</option>
                    <option>50</option>
                    <option>51</option>
                    <option>52</option>
                    <option>53</option>
                    <option>54</option>
                    <option>55</option>
                    <option>56</option>
                    <option>57</option>
                    <option>58</option>
                    <option>59</option>
                  </select>
                </td>
                <td>结束时间：</td>
                <td>
                  <select
                    class="form-control"
                    style="width:72px"
                  >
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option selected>12</option>
                  </select> :
                  <select
                    class="form-control"
                    style="width:72px"
                  >
                    <option>00</option>
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                    <option>13</option>
                    <option>14</option>
                    <option>15</option>
                    <option>16</option>
                    <option>17</option>
                    <option>18</option>
                    <option>19</option>
                    <option>20</option>
                    <option>21</option>
                    <option>22</option>
                    <option>23</option>
                    <option>24</option>
                    <option>25</option>
                    <option>26</option>
                    <option>27</option>
                    <option>28</option>
                    <option>29</option>
                    <option>30</option>
                    <option>31</option>
                    <option>32</option>
                    <option>33</option>
                    <option>34</option>
                    <option>35</option>
                    <option>36</option>
                    <option>37</option>
                    <option>38</option>
                    <option>39</option>
                    <option>40</option>
                    <option>41</option>
                    <option>42</option>
                    <option>43</option>
                    <option>44</option>
                    <option>45</option>
                    <option>46</option>
                    <option>47</option>
                    <option>48</option>
                    <option>49</option>
                    <option>50</option>
                    <option>51</option>
                    <option>52</option>
                    <option>53</option>
                    <option>54</option>
                    <option>55</option>
                    <option>56</option>
                    <option>57</option>
                    <option>58</option>
                    <option>59</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td>放号数量：</td>
                <td>
                  <input
                    type="text"
                    class="form-control"
                    v-model="NumberCalls"
                  />
                </td>
                <td>挂号类别：</td>
                <td>
                  <select class="form-control">
                    <option>普通号</option>
                    <option>急诊号</option>
                    <option>副主任专家号</option>
                    <option>主任专家号</option>
                    <option>免费号</option>
                    <option>专科号</option>
                  </select>
                </td>
              </tr>
            </tbody>
            <thead>
              <tr>
                <th colspan="4">下午开诊</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>是否开诊：</td>
                <td>
                  <select
                    class="form-control"
                    style="width: 72px"
                    @change="getXiaons()"
                    v-model="WhOpctorx"
                  >
                    <option :value="1">是</option>
                    <option :value="0">否</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td>开始时间：</td>
                <td>
                  <select
                    class="form-control"
                    style="width: 72px"
                  >
                    <option>13</option>
                    <option>14</option>
                    <option>15</option>
                    <option>16</option>
                    <option>17</option>
                    <option>18</option>
                    <option>19</option>
                    <option>20</option>
                    <option>21</option>
                    <option>22</option>
                    <option>23</option>
                  </select> :
                  <select
                    class="form-control"
                    style="width: 72px"
                  >
                    <option>00</option>
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                    <option>13</option>
                    <option>14</option>
                    <option>15</option>
                    <option>16</option>
                    <option>17</option>
                    <option>18</option>
                    <option>19</option>
                    <option>20</option>
                    <option>21</option>
                    <option>22</option>
                    <option>23</option>
                    <option>24</option>
                    <option>25</option>
                    <option>26</option>
                    <option>27</option>
                    <option>28</option>
                    <option>29</option>
                    <option>30</option>
                    <option>31</option>
                    <option>32</option>
                    <option>33</option>
                    <option>34</option>
                    <option>35</option>
                    <option>36</option>
                    <option>37</option>
                    <option>38</option>
                    <option>39</option>
                    <option>40</option>
                    <option>41</option>
                    <option>42</option>
                    <option>43</option>
                    <option>44</option>
                    <option>45</option>
                    <option>46</option>
                    <option>47</option>
                    <option>48</option>
                    <option>49</option>
                    <option>50</option>
                    <option>51</option>
                    <option>52</option>
                    <option>53</option>
                    <option>54</option>
                    <option>55</option>
                    <option>56</option>
                    <option>57</option>
                    <option>58</option>
                    <option>59</option>
                  </select>
                </td>
                <td>结束时间：</td>
                <td>
                  <select
                    class="form-control"
                    style="width: 72px"
                  >
                    <option>13</option>
                    <option>14</option>
                    <option>15</option>
                    <option>16</option>
                    <option selected>17</option>
                    <option>18</option>
                    <option>19</option>
                    <option>20</option>
                    <option>21</option>
                    <option>22</option>
                    <option>23</option>
                  </select> :
                  <select
                    class="form-control"
                    style="width: 72px"
                  >
                    <option>00</option>
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                    <option>13</option>
                    <option>14</option>
                    <option>15</option>
                    <option>16</option>
                    <option>17</option>
                    <option>18</option>
                    <option>19</option>
                    <option>20</option>
                    <option>21</option>
                    <option>22</option>
                    <option>23</option>
                    <option>24</option>
                    <option>25</option>
                    <option>26</option>
                    <option>27</option>
                    <option>28</option>
                    <option>29</option>
                    <option>30</option>
                    <option>31</option>
                    <option>32</option>
                    <option>33</option>
                    <option>34</option>
                    <option>35</option>
                    <option>36</option>
                    <option>37</option>
                    <option>38</option>
                    <option>39</option>
                    <option>40</option>
                    <option>41</option>
                    <option>42</option>
                    <option>43</option>
                    <option>44</option>
                    <option>45</option>
                    <option>46</option>
                    <option>47</option>
                    <option>48</option>
                    <option>49</option>
                    <option>50</option>
                    <option>51</option>
                    <option>52</option>
                    <option>53</option>
                    <option>54</option>
                    <option>55</option>
                    <option>56</option>
                    <option>57</option>
                    <option>58</option>
                    <option>59</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td>放号数量：</td>
                <td>
                  <input
                    type="text"
                    class="form-control"
                    v-model="CountCall"
                  />
                </td>
                <td>挂号类别：</td>
                <td>
                  <select class="form-control">
                    <option>普通号</option>
                    <option>急诊号</option>
                    <option>副主任专家号</option>
                    <option>主任专家号</option>
                    <option>免费号</option>
                    <option>专科号</option>
                  </select>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="modal-footer">
          <button
            type="button"
            class="btn btn-default"
            @click="PostblaBg()"
          >关闭</button>
          <button
            type="button"
            class="btn btn-primary"
            @click="Prosuccess()"
          >保存</button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "typesetting",
  data () {
    return {
      msg: "RegisteredFees 下的 typesetting",
      name: "<",
      Management: "WorkManagement",
      options: {
        section: "",
        doctor: "",
        hospital_id: ""
      },
      blaBg: false,
      WhethOpctor: "1",
      NumberCalls: "20",
      WhOpctorx: "1",
      CountCall: "20",
      Shang: {
        oneShang: "20",
        TwoShang: "20",
        ThreeShang: "20",
        FourShang: "20",
        FiveShang: "20",
        SixShang: "20",
        ZeroShang: "20"
      },
      Xia: {
        oneShang: "20",
        TwoShang: "20",
        ThreeShang: "20",
        FourShang: "20",
        FiveShang: "20",
        SixShang: "20",
        ZeroShang: "20"
      },
      index: "0"
    };
  },
  methods: {
    toJump (vueName) {
      this.Management = vueName;
    },
    SearchSuling () {
      var data = {
        model: "1.门急诊挂号-[排班]",
        code: "1007",
        input: {
          doctor: "", //医生代码,
          hospital_id: "", //医院编号,
          section: "" //科室代码
        }
      };
      console.log(data);
      this.$post("CloudHIS/Business_Handle", data)
        .then(res => {
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    queryG () {
      //   FirstOcx.AboutBox();
      // var data = {
      //   model: "11.综合维护-用户与科室对照",
      //   code: "11142",
      //   // 11122
      //   input: {
      //     section_id: -1, //科室代码
      //     user_id: -1 //用户代码
      //   }
      // };
      // this.$post("CloudHIS/Business_Handle", data)
      //   .then(res => {
      //     console.log(res);
      //   })
      //   .catch(err => {
      //     console.log(err);
      //   });

      var data = {
        code: "get_sys_dict",
        input: {
          code: "numb_logo"
        }
      };
      this.$post("CloudHIS/getRedisDataByCode", data)
        .then(res => {
          console.log(res.data);
        })
        .catch(err => {
          console.log(err);
        });
    },
    JumpblaBg (id) {
      this.blaBg = true;
      this.index = id;

      //  "Code": "1011",
      //  "Notice": "获取号别排班信息",
      //  "Input_Remark": "{ clinic_class :号别标识,hospital_id :医院编号}",
    },
    PostblaBg () {
      this.blaBg = false;
    },
    getoptions () {
      // console.log(this.WhethOpctor);
      if (this.WhethOpctor == "1") {
        this.NumberCalls = "20";
      } else {
        this.NumberCalls = "0";
      }
    },
    getXiaons () {
      // console.log(this.WhOpctorx);
      if (this.WhOpctorx == "1") {
        this.CountCall = "20";
      } else {
        this.CountCall = "0";
      }
    },
    Prosuccess () {
      console.log(this.index);
      console.log(this.WhethOpctor);
      console.log(this.NumberCalls);
      var data = {
        model: "1.门急诊挂号-[排班]",
        code: "1010",
        input: {
          // appointment_limits :预约可用号数,
          // clinic_class :号别标识,
          // hospital_id :医院编号,
          // register_limits :this.NumberCalls,
          // time_flag :'上午',
          // week :this.index
        }
      };
      this.$post("CloudHIS/Business_Handle", data)
        .then(res => {
          console.log(res);
          if (res.code == 0) {
            this.Proxiasuccess();
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    Proxiasuccess () {
      console.log(this.WhOpctorx);
      console.log(this.CountCall);
      var data = {
        model: "1.门急诊挂号-[排班]",
        code: "1010",
        input: {
          // appointment_limits :预约可用号数,
          // clinic_class :号别标识,
          // hospital_id :医院编号,
          // register_limits :this.CountCall,
          // time_flag :下午,
          // week :this.index
        }
      };
      this.$post("CloudHIS/Business_Handle", data)
        .then(res => {
          console.log(res);
          this.blaBg = false;
          this.FanPresues();
        })
        .catch(err => {
          console.log(err);
        });
    },
    FanPresues () {
      if (this.index == "1") {
        this.Shang.oneShang = this.NumberCalls;
        this.Xia.oneShang = this.CountCall;
      } else if (this.index == "2") {
        this.Shang.TwoShang = this.NumberCalls;
        this.Xia.TwoShang = this.CountCall;
      } else if (this.index == "3") {
        this.Shang.ThreeShang = this.NumberCalls;
        this.Xia.ThreeShang = this.CountCall;
      } else if (this.index == "4") {
        this.Shang.FourShang = this.NumberCalls;
        this.Xia.FourShang = this.CountCall;
      } else if (this.index == "5") {
        this.Shang.FiveShang = this.NumberCalls;
        this.Xia.FiveShang = this.CountCall;
      } else if (this.index == "6") {
        this.Shang.SixShang = this.NumberCalls;
        this.Xia.SixShang = this.CountCall;
      } else if (this.index == "0") {
        this.Shang.ZeroShang = this.NumberCalls;
        this.Xia.ZeroShang = this.CountCall;
      }
    }
  },
  created () {
    if (this.$route.query.Token) {
      localStorage.setItem('Token', this.$route.query.Token)
    }
  }
};
</script>
